﻿using System;
using System.Collections.Generic;
using System.Text;

namespace cefsharpcore7_ch2
{
    /// <summary>
    /// out修饰符
    /// 不需要在传入函数之前进行赋值
    /// 必须在函数结束之前赋值
    /// </summary>
    class OutKeyWordExample1
    {
        static void Split(string name, out string firstNames, out string lastname)
        {
            int i = name.LastIndexOf(' ');
            Console.WriteLine(i);
            firstNames = name.Substring(0, i);
            lastname = name.Substring(i + 1);
        }

        static void Main()
        {
            string a, b;
            Split("Stevie Ray Vaugha",out a,out b);
            Console.WriteLine(a);
            Console.WriteLine(b);

            //调用含有out参数的方法时直接声明变量
            Split("Stevie Ray Vaugha", out string c, out string d);
            //丢弃不关心的参数，一次调用可以引入多个丢弃符号
            Split("Stevie Ray Vaugha", out string e, out string _);

        }
    }
}
